package com.tanhua.app.controller;

import com.tanhua.app.controllerservice.TestSoulService;
import com.tanhua.domain.db.Answers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Richard Wang
 * @date 2021/9/4 15:18
 */
@RestController
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    @GetMapping(name = "问卷列表",value = "/testSoul")
    public ResponseEntity testSoulQuestionList(){
        return testSoulService.testSoulQuestionList();
    }

    @PostMapping(name = "提交问卷",value = "/testSoul")
    public ResponseEntity submitQuestionList(@RequestBody Map answers){
        List list = (List) answers.get("answers");
        return testSoulService.submitQuestionList(list);
    }

    @GetMapping(name = "查看结果",value = "/testSoul/report/{id}")
    public ResponseEntity checkReport(@PathVariable("id")Integer reportId){

        return testSoulService.checkReport(reportId);
    }
}
